<?php
/*  
  Copyright (c) 2010-02 SongCMS 
  SongCMS All Rights Reserved. 
  Support:www.SongCMS.com
  QQ:544255858   19951025
  Author:Song  Version:3.17
  Date:2010-08-12 09:28:32
*/

include_once('Admin.php');
!is_numeric($_GET['page']) ? $page = 1 : $page = (int)($_GET['page']);
$PageCount = 20;
if($_GET['a']=='Del' && is_numeric($_GET['ID'])){
	if($db->ExecuteSQL("DELETE FROM `{$dbprefix}survey` WHERE `ID` = '{$_GET['ID']}' LIMIT 1;")){
		$admin -> delcomment(3,$_GET['ID']);
		AdminLog(3,$Lang,'删除调查(ID:' . $_GET['ID'] . ')，结果：删除成功！'); 
		MsgBox (0,'',"SurveyManage.php?page={$page}&Lang={$Lang}");		
	}else{
		AdminLog(3,$Lang,'删除调查(ID:' . $_GET['ID'] . ')，结果：删除失败！'); 
		MsgBox (1,'删除失败！','-1');	
	}	
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="./images/adminstyle.css" rel="stylesheet" type="text/css" />
<link rel="Shortcut Icon" href="../favicon.ico">
<link rel="Bookmark" href="../favicon.ico">
<script src="../js/csshovernotie6.js" type="text/javascript"></script>
</head>
<body>
<br />
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr class="Notodd">
		<td><?php TopLang();?></td>
		<td align="right">
			<input type="button" value="添加调查" onClick="javascript:location.href='SurveyAdd.php?Lang=<?php echo $Lang?>'">
		</td>
	</tr>
</table>
<table width="98%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC">
  <tr>
    <td colspan="6" align="center" class="Main_Title">调查管理<?php echo $OnWebLangName?></td>
  </tr>
  <tr class="odd">
    <td height="20" align="center"><strong>ID</strong></td>
    <td height="20" align="center"><strong>调查标题</strong></td>
    <td align="center"><strong>开始时间</strong></td>
    <td align="center"><strong>结束时间</strong></td>
    <td align="center"><strong>投票人数</strong></td>
    <td align="center"><strong>管理选项</strong></td>
  </tr>
<?php
$SQL = "SELECT * FROM `{$dbprefix}survey` ";
$SQL .= "WHERE `SurveyLang` = $Lang ";
$RsCount = count($db->SelectSQL($SQL)); //总记录数
$SQL .= "ORDER BY `ID` DESC "; 
$SQL .= "LIMIT " . ($page-1)*$PageCount . " , " . $PageCount . " ";
$sArray = $db->SelectSQL($SQL,1);
foreach ($sArray as $i => $n){
	$SurveyCount = array_sum(explode('|',$n['SurveyCount']));
	$manage = "<a href=\"SurveyUpDate.php?page={$page}&Lang={$Lang}&ID={$n['ID']}\">修改</a> | ";
	$manage .= "<a onClick=\"return confirm('确定要删除该产品吗？');\" href=\"SurveyManage.php?page={$page}&Lang={$Lang}&a=Del&ID={$n['ID']}\">删除</a> | ";
	$manage .= "<a target=\"_blank\" href=\"../?fsurvey/l{$Lang}/i{$n['ID']}\">查看</a>";
	echo "<tr class=\"odd\">
	<td height=\"20\" align=\"center\">{$n['ID']}</td>
	<td align=\"center\">{$n['SurveyTitle']}</td>
	<td align=\"center\">{$n['SurveyStart']}</td>
	<td align=\"center\">{$n['SurveyEnd']}</td>
	<td align=\"center\">{$SurveyCount}</td>
	<td align=\"center\">{$manage}</td>
	</tr>";
}
?>    
 	<tr class="odd">
    	<td colspan="6" height="35" align="center"><?php if($RsCount>0) {echo pages('Lang=' . $Lang);} else {echo '没有调查数据！<a href="SurveyAdd.php?Lang=' . $Lang . '">添加调查</a>';}?></td>
    </tr>
  </table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="6">
	<tr class="Notodd">
		<td style="color:#333333; line-height:20px;">&nbsp;</td>
	</tr>
</table>  
</body>
</html>